<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!--edge浏览器H5兼容设置-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--360浏览器H5兼容设置-->
    <meta name="renderer" content="webkit" />
    <title>电脑商城</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script src="../bootstrap3/js/holder.js"></script>
    <link href="../bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="../bootstrap3/jquery-1.9.1.min.js"></script>
    <script src="../bootstrap3/js/bootstrap.js"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" href="../bootstrap3/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="../css/layout.css" />
    <link rel="stylesheet" type="text/css" href="../css/top.css" />
    <link rel="stylesheet" type="text/css" href="../css/footer.css" />
    <link rel="stylesheet" type="text/css" href="../css/product.css" />
    <link rel="stylesheet" type="text/css" href="../css/imgmove.css" />
    <script src="../js/product.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/imgmove.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<!--头部-->
<header class="header">
    <!--电脑商城logo-->
    <div class="row">
        <div class="col-md-3">
            <a href="index_business.html">
                <img src="../images/index/stumalllogo.png" />
            </a>
        </div>
        <!--快捷选项-->
        <div class="col-md-9 top-item">
            <ul class="list-inline pull-right">
                <li><a href="orders.html"><span class="fa fa-file-text"></span>&nbsp;订单</a></li>
                <li class="li-split">|</li>
                <li><a href="cart.html"><span class="fa fa-cart-plus"></span>&nbsp;购物车</a></li>
                <li class="li-split">|</li>
                <li>
                    <!--下列列表按钮 ：管理-->
                    <div class="btn-group">
                        <button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown">
                            <span id="top-dropdown-btn"><span class="fa fa-gears"></span>&nbsp;管理 <span class="caret"></span></span>
                        </button>
                        <ul class="dropdown-menu top-dropdown-ul" role="menu">
                            <li><a href="password_business.html">修改密码</a></li>
                            <li><a href="userdata_business.html">个人资料</a></li>
                            <li><a href="upload_business.html">上传营业执照</a></li>
                            <li><a href="address_business.html">收货管理	</a></li>
                        </ul>
                    </div>
                </li>
                <li class="li-split">|</li>
                <li><a href="login.html"><span class="fa fa-user"></span>&nbsp;登录</a></li>
            </ul>
        </div>
    </div>
</header>
<!--导航 -->
<!--分割导航和顶部-->
<div class="row top-nav">
    <div class="col-md-6">
        <ul class="nav nav-pills">
            <li>
                <a href="#"></a>
            </li>
            <li class="active"><a href="index_business.html"><span class="fa fa-home"></span></a></li>
        </ul>
    </div>

</div>
<!--头部结束-->
<!--导航结束-->
<!--商品信息展示开始-->
<div class="container">
    <div data="1" class="img-big move-img col-md-6">
        <img id="product-image-1-big" src="../images/portal/11DELLran7000R1605Ssilvery/1_big.png" class="img-responsive" />
    </div>
    <div data="2" class="img-big move-img col-md-6">
        <img id="product-image-2-big" src="../images/portal/11DELLran7000R1605Ssilvery/2_big.png" class="img-responsive" />
    </div>
    <div data="3" class="img-big move-img col-md-6">
        <img id="product-image-3-big" src="../images/portal/11DELLran7000R1605Ssilvery/3_big.png" class="img-responsive" />
    </div>
    <div data="4" class="img-big move-img col-md-6">
        <img id="product-image-4-big" src="../images/portal/11DELLran7000R1605Ssilvery/4_big.png" class="img-responsive" />
    </div>
    <div data="5" class="img-big move-img col-md-6">
        <img id="product-image-5-big" src="../images/portal/11DELLran7000R1605Ssilvery/5_big.png" class="img-responsive" />
    </div>
    <br>
    <div>
        <table class="col-md-10" style="width: max-content;height: 50px">
            <tr>
                <td data="1" class="img-small col-md-2">
                    <img id="product-image-1" src="../images/portal/11DELLran7000R1605Ssilvery/1.jpg"/>
                </td>
                <td data="2" class="img-small col-md-2">
                    <img id="product-image-2" src="../images/portal/11DELLran7000R1605Ssilvery/2.jpg"/>
                </td>
                <td data="3" class="img-small col-md-2">
                    <img id="product-image-3" src="../images/portal/11DELLran7000R1605Ssilvery/3.jpg"/>
                </td>
                <td data="4" class="img-small col-md-2">
                    <img id="product-image-4" src="../images/portal/11DELLran7000R1605Ssilvery/4.jpg"/>
                </td>
                <td data="5" class="img-small col-md-2">
                    <img id="product-image-5" src="../images/portal/11DELLran7000R1605Ssilvery/5.jpg"/>
                </td>
            </tr>
        </table>
    </div>
    <div class="col-md-6">
        <h3 id="product-title" class="col-md-12 title-row-1">戴尔Dell 燃700R1605银色</h3>
        <p id="product-sell-point" class="col-md-12 text-row-1"><small>仅上海，广州，沈阳仓有货！预购从速！</small></p>
        <div class="col-md-12 price-bar">
            <small>售价：</small> ¥<span id="product-price">4899.00</span>
            <div><small>*退货补运费 *7天无理由退货 *24小时快速退款 </small></div>
            <div>
                <small>库存：</small> <small id="product-num">100</small>
                <small>历史售量：</small> <small id="product-priority">100</small>
            </div>
            <div>
                <small>购买人数：</small> <small id="product-sell_person">100</small>
                <small>评价分数：</small> <small id="product-judge_mark">10</small>
            </div>
        </div>
        <form class="form-inline product-form col-md-12" role="form">
            <div class="col-md-12 form-space">
                <label for="num">数量：</label>
                <input id="numDown" type="button" value="-" class="num-btn" />
                <input id="num" type="text" size="2" readonly="readonly" class="num-text" value="1">
                <input id="numUp" class="num-btn" type="button" value="+" />
            </div>
            <div class="col-md-12 form-space">
                <p><small><b>北信科二手商城</b>发货并提供售后服务</small></p>
            </div>
        </form>
    </div>
    <!--商品信息展示结束-->
    <div class="col-md-offset-1 col-md-10">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2 class="panel-title">商品历史评价</h2>
            </div>
            <form role="form">
                <table class="cart-table" width="100%">
                    <thead>
                    <tr>
                        <th width="5%">用户id</th>
                        <th width="5%">商家id</th>
                        <th width="5%">订单id</th>
                        <th width="10%">商品id</th>
                        <th width="20%">商品评价</th>
                        <th width="20%">商家评价</th>
                        <th width="20%">评价分数</th>
                        <th width="20%">商家回复</th>
                    </tr>
                    </thead>
                    <tbody id="comment-list" class="cart-body">
                    <tr>
                        <td>50</td>
                        <td>50</td>
                        <td>50</td>
                        <td>10000005</td>
                        <td>不错不错不错不错不错不错</td>
                        <td>不错不错不错不错不错不错</td>
                        <td>10</td>
                        <td>谢谢谢谢谢谢谢谢</td>
                    </tr>
                    </tbody>
                </table>
                <div class="total-bar">
                </div>
                <label class="col-md-2 control-label"></label>
            </form>
        </div>
    </div>
    <!--售后信息开始-->
    <div class="col-md-offset-1 col-md-10">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2 class="panel-title">售后保障</h2>
            </div>
            <div class="panel-body ">
                <div class="row">
                    <div class="col-md-1 saled-icon"><span class="fa fa-shield"></span></div>
                    <div class="col-md-11 saled-title">正品保障</div>
                </div>
                <div class="row">
                    <p class="col-md-offset-1 col-md-11 saled-content">北信科二手商城向您保证所售商品均为正品行货。</p>
                </div>
                <div class="row">
                    <div class="col-md-1 saled-icon"><span class="fa fa-wrench"></span></div>
                    <div class="col-md-11 saled-title">厂家服务</div>
                </div>
                <div class="row">
                    <p class="col-md-offset-1 col-md-11 saled-content">本产品全国联保，享受三包服务，质保期为：二年质保</p>
                </div>
                <div class="row">
                    <div class="col-md-1 saled-icon"><span class="fa fa-heartbeat"></span></div>
                    <div class="col-md-11 saled-title">郑重承诺</div>
                </div>
                <div class="row">
                    <p class="col-md-offset-1 col-md-11 saled-content">北信科二手商城销售并发货的商品，提供发票和相应的售后服务。请放心购买！
                        <br /> 注：因厂家会在没有任何提前通知的情况下更改产品包装、产地或者一些附件，本司不能确保客户收到的货物与商城图片、产地、附件说明完全一致。只能确保为原厂正货！并且保证与当时市场上同样主流新品一致。若本商城没有及时更新，请大家谅解！
                    </p>
                </div>
                <div class="row">
                    <div class="col-md-1 saled-icon"><span class="fa fa-globe"></span></div>
                    <div class="col-md-11 saled-title">全国联保</div>
                </div>
                <div class="row">
                    <p class="col-md-offset-1 col-md-11 saled-content">
                        凭质保证书及发票，可享受全国联保服务（奢侈品、钟表除外；奢侈品、钟表由电脑商城联系保修，享受法定三包售后服务），与您亲临商场选购的商品享受相同的质量保证。电脑商城还为您提供具有竞争力商品价格和运费政策，请您放心购买！
                        <br /> 注：因厂家会在没有任何提前通知的情况下更改产品包装、产地或者一些附件，本司不能确保客户收到的货物与商城图片、产地、附件说明完全一致。只能确保为原厂正货！并且保证与当时市场上同样主流新品一致。若本商城没有及时更新，请大家谅解！
                    </p>
                </div>
                <div class="row">
                    <div class="col-md-1 saled-icon"><span class="fa fa-reply"></span></div>
                    <div class="col-md-11 saled-title">无忧退货</div>
                </div>
                <div class="row">
                    <p class="col-md-offset-1 col-md-11 saled-content">客户购买北信科二手商城商品24小时内（含24小时，客户支付之时起），在保证商品完好的前提下，经商家同意可退款退货。（超过24小时将无法退货，请您及时查验商品，若有异议，请联系管理员）</p>
                </div>
                <div class="saled-content">
                    <small><b>权利声明：</b><br />
                        所有商品信息、商品咨询等内容，是北信科二手商城重要的经营资源，未经许可，禁止非法转载使用。<br />
                        注：北信科二手商城商品信息均来自于合作方，其真实性、准确性和合法性由信息拥有者（合作方）负责。北信科二手商城不提供任何保证，并不承担任何法律责任。</small>
                </div>
            </div>
        </div>
    </div>
</div>
<!--页脚开始-->
<div class="clearfix"></div>

<!--页脚结束-->
<script type="text/javascript" src="../js/jquery-getUrlParam.js"></script>
<script type="text/javascript">

    let id = $.getUrlParam("id");
    console.log("id=" + id);
    $(document).ready(function() {
        $.ajax({
            url: "/product/" + id + "/details",
            type: "GET",
            dataType: "JSON",
            success: function(json) {
                if (json.state == 200) {
                    console.log("title=" + json.data.title);
                    //<div>aaa</div>
                    //html("aaa")
                    $("#product-title").html(json.data.title);
                    $("#product-sell-point").html(json.data.sellPoint);
                    $("#product-price").html(json.data.price);
                    $("#product-num").html(json.data.num);
                    $("#product-priority").html(json.data.priority);
                    $("#product-sell_person").html(json.data.sellPersons);
                    $("#product-judge_mark").html(json.data.judgeMark);

                    for (let i = 1; i <= 5; i++) {
                        $("#product-image-" + i + "-big").attr("src", ".." + json.data.image + i + "_big.png");
                        $("#product-image-" + i).attr("src", ".." + json.data.image + i + ".jpg");
                    }
                } else if (json.state == 4006) { // 商品数据不存在的异常
                    location.href = "index.html";
                } else {
                    alert("获取商品信息失败！" + json.message);
                }
            }
        });
    });

    /*$("#btn-add-to-cart").click(function() {
        $.ajax({
            url: "/cart/add_to_cart",
            type: "POST",
            data: {
                "pid": id,
                "amount": $("#num").val()//num按钮的控件
            },//ajax函数中data参数的数据设置的方式1.data：$("form表单选择").serialize() 当参数过多并且在同一个表单中，字符串的提交等
            //2.data:new FormData($("form表单选择")[0])只适用提交文件
            //data:"username=AAA",适用于参数值固定且参数值列表有限，可手动拼接
            //JSON格式提交 data:{"username":"ABC"   "age";18   "sex":0}
            dataType: "json",
            success: function (json) {
                if (json.state == 200) {
                    alert("加入购物车成功！");
                } else {
                    alert("加入购物车失败！" + json.message);
                }
            },
            error: function (xhr) {
                alert("请先登录！" + xhr.status);
            }
        });
    });*/
    showProductCommentList();
    function showProductCommentList() {
        $("#comment-list").empty();
        //通过商品id查询历史评价
        $.ajax({
            url: "/comment/find_product",
            type: "GET",
            data:"pid="+id,
            dataType: "JSON",
            success: function(json) {
                let list = json.data;
                console.log("count=" + list.length);
                console.log(json.data);
                for (let i = 0; i < list.length; i++) {
                    let tr = '<tr>' +
                        '<td>#{uid}</td>' +
                        '<td>#{bid}</td>' +
                        '<td>#{oid}</td>' +
                        '<td>#{pid}</td>'+
                        '<td>#{pComment}</td>'+
                        '<td>#{bComment}</td>'+
                        '<td>#{judgeMark}</td>'+
                        '<td>#{reply}</td>'+
                        '</tr>'
                    tr = tr.replace(/#{uid}/g, list[i].uid);
                    tr = tr.replace(/#{bid}/g, list[i].bid);
                    tr = tr.replace(/#{oid}/g, list[i].oid);
                    tr = tr.replace(/#{pid}/g, list[i].pid);
                    tr = tr.replace(/#{pComment}/g, list[i].pcomment);
                    tr = tr.replace(/#{bComment}/g, list[i].bcomment);
                    tr = tr.replace(/#{judgeMark}/g, list[i].judgeMark);
                    tr = tr.replace(/#{reply}/g, list[i].reply);
                    $("#comment-list").append(tr);
                }
            }
        });
    }
</script>
</body>

</html>